package com.xsprite.managesys.dao;


import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class SessionManager {
	
	 private static SessionManager instance;
	 
	 public static SessionManager getInstance(){
		 if(instance == null){
			 instance = new SessionManager();
		 }
		 return instance;
	 }
	 
	 private SqlSessionFactory sessionFactory;
	 
	 private SessionManager(){
		 String resource = "conf.xml";
		 InputStream is = SessionManager.class.getClassLoader().getResourceAsStream(resource);
		 sessionFactory = new SqlSessionFactoryBuilder().build(is);
		 
	 }
	 
	 public SqlSession getSession(){
		 SqlSession session = sessionFactory.openSession();
		 return session;
	 }
}
